package jxau.jwgl.api;

import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;

import java.util.Map;

/**
 * UserApi // TODO 功能不完全
 *
 * @author LongShu 2017/04/03
 */
@HttpServiceApi
public interface UserApi {

    // "[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}"
    String GUID_REG = "\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}";

    /**
     * 登录
     *
     * @param username 学号
     * @param password 密码
     * @return
     */
    @FormUrlEncoded
    @POST(JWGLServerApiConfig.login)
    Call<MessageData<Map<String, String>>> login(@Field("username") String username,
                                                 @Field("password") String password);

    @FormUrlEncoded
    @POST(JWGLServerApiConfig.userInfo)
    Call<MessageData<Map<String, String>>> userInfo(@Path("guid") String guid, @Field("Xh") String username);

    @FormUrlEncoded
    @POST(JWGLServerApiConfig.checkGuid)
    Call<MessageData<Object>> checkGuid(@Field("guid") String guid);


    @GET(JWGLServerApiConfig.exit)
    Call<ResponseBody> exit(@Path("guid") String guid);

}
